<div class="form">

<?php $form = $this->beginWidget('GxActiveForm', array(
	'id' => 'pages-form',
	'enableAjaxValidation' => false,
));
?>
	<div class="mini-bl">
	<table>
		<tr>
			<td><?php echo $form->labelEx($model,'status'); ?></td>
			<td><?php echo $form->dropDownList($model,'status',Lookup::items('PostStatus')); ?></td>
		</tr>
		<tr>
			<td><?php echo $form->labelEx($model,'ordering'); ?></td>
			<td><?php echo $form->textField($model, 'ordering'); ?>
			<?php echo $form->error($model,'ordering'); ?>
			</td>
		</tr>
		<tr>
		<td><?php echo $form->labelEx($model,'created'); ?></td>
		<td colspan="3">
		<?php 
			$this->widget('ext.widgets.CJuiDateTimePicker.CJuiDateTimePicker',array(
		        'model'=>$model, //Model object
		        'attribute'=>'created', //attribute name
		        'mode'=>'datetime', //use "time","date" or "datetime" (default)
				'options'=>array()
		    ));
		?>
		<?php echo $form->error($model,'created'); ?>
		</td><!-- row -->
		<tr>
		<td><?php echo $form->labelEx($model,'created_by'); ?></td>
		<td>
		<?php 
		$u_create = iUsers::model()->findByPk($model->created_by);
		if(is_object($u_create)) 
			echo $u_create->username;
		?>
		</td>
		</tr>
		<tr>
		<td><?php echo $form->labelEx($model,'modified'); ?></td>
		<td colspan="3"><?php 
					$this->widget('ext.widgets.CJuiDateTimePicker.CJuiDateTimePicker',array(
				        'model'=>$model, //Model object
				        'attribute'=>'modified', //attribute name
				        'mode'=>'datetime', //use "time","date" or "datetime" (default)
						'options'=>array()
				    ));
				?>
				<?php echo $form->error($model,'modified'); ?>
		</td>
		<tr>
		<td><?php echo $form->labelEx($model,'modified_by');?></td>
		<td><?php $u_modified = iUsers::model()->findByPk($model->modified_by);
				if(is_object($u_modified))
					echo $u_modified->username;
				?>
		</td>
		</tr>
	</table>
	</div>
	<p class="note">
		<?php echo Yii::t('app', 'Fields with'); ?> <span class="required">*</span> <?php echo Yii::t('app', 'are required'); ?>.
	</p>

	<?php echo $form->errorSummary($model); ?>
	<div class="row">
	<?php echo $form->labelEx($model,'title'); ?>
	<?php echo $form->textField($model, 'title', array('maxlength' => 255, 'class'=>'textField-l')); ?>
	<?php echo $form->error($model,'title'); ?>
	</div><!-- row -->
	<div class="row">
	<?php echo $form->labelEx($model,'alias'); ?>
	<?php echo $form->textField($model, 'alias', array('class'=>'textField-l')); ?>
	<?php echo $form->error($model,'alias'); ?>
	</div><!-- row -->
	<div class="row">
	<?php echo $form->labelEx($model,'parent'); ?>
	<?php 
	$meid = ($model->id>0)?$model->id:0;
	$pages_list = Pages::model()->findAll("type = 'page' AND status=".Pages::STATUS_PUBLISHED." ORDER BY position ASC");
	$pages = CHtml::listData($pages_list, 'id', 'page_tree');
	echo '<select name="Pages[parent]" id="Pages_parent">';
	echo '<option value="">--None--</option>';
	foreach($pages as $key => $page):
		if($key==$meid){
			echo "<option disabled='disabled'>$page</option>";
		}else{
			if($model->parent==$key){
				$selected = "selected";
			}else{
				$selected="";
			}
			echo "<option value='$key' $selected>$page</option>";
		}
		
	endforeach;
	echo '</select>';
	?>
	<?php echo $form->error($model,'parent'); ?>
	</div><!-- row -->
	<div class="row">
	<?php echo $form->labelEx($model,'fulltext'); ?>
	<?php
	$this->widget('application.extensions.elrte.elRTE', array(
	    'selector'=>'Pages_fulltext',
	    'doctype' => '<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">',
	    'cssClass' => 'el-rte',
	    'absoluteURLs' => 'false',
	    'allowSource' => 'true',
	    'lang' => 'en',
	    'styleWithCSS' => 'true',
	    'height' => '500',
	    'width' => '100%',
	    'fmAllow' => 'true',
	    'toolbar' => 'maxi',
	 ));
	  echo $form->textArea($model, 'fulltext'); 
	?>
	<?php echo $form->error($model,'fulltext'); ?>
	</div><!-- row -->
	
	<div class="row">
	<?php echo $form->labelEx($model,'metakey'); ?>
	<?php echo $form->textArea($model, 'metakey', array('class'=>'textarea-m')); ?>
	<?php echo $form->error($model,'metakey'); ?>
	</div><!-- row -->
	<div class="row">
	<?php echo $form->labelEx($model,'metadesc'); ?>
	<?php echo $form->textArea($model, 'metadesc', array('class'=>'textarea-m')); ?>
	<?php echo $form->error($model,'metadesc'); ?>
	</div><!-- row -->
<?php
echo GxHtml::submitButton(Yii::t('app', 'Save'), array('id'=>'s-bt','style'=>'display: none'));
$this->endWidget();
?>
</div><!-- form -->
<script type="text/javascript">
jQuery(document).ready(function(){
	jQuery("#Pages_title").blur(function(){
		jQuery.ajax({
			url: '<?php echo Yii::app()->createUrl('/admin_news/common/renalias');?>',
			data: {title:this.value},
			dataType:'json',
			success: function(msg){
			   	jQuery("#Pages_alias").attr("value",msg.title)
			  }
		})
	})
})
</script>